package com.ffapp.rainmonitorcustom.bean;


import com.ffapp.rainmonitorcustom.R;

import java.util.ArrayList;

import my.LogUtil;
import my.TimeUtils;

public class HistoryChartListBean extends BaseListBeanBc {

    private ArrayList<HistoryChartListData> list = new ArrayList<HistoryChartListData>();

    public ArrayList<HistoryChartListData> getList() {
        return list;
    }

    public void setList(ArrayList<HistoryChartListData> list) {
        this.list = list;
    }

    public void addListBean(HistoryChartListBean listbean) {
        if (listbean == null)
            return;
        if (this.getCurrentPage() == INIT_PAGE) {
            setList(listbean.getList());
        } else {
            if (list == null)
                list = new ArrayList<HistoryChartListData>();
            list.addAll(listbean.getList());
        }
        setListBeanData(listbean);
    }

    public ArrayList<String> getListNames(){
        ArrayList<String> listStr = new ArrayList<>();
        for(HistoryChartListData data:list){
            listStr.add(data.getStnm());
        }
        return listStr;
    }


    public ChartInfoBean getChartInfoBeanPosition(BaseListData baseListData){
        ChartInfoBean chartInfoBean = new ChartInfoBean();
        ArrayList<String> legend = new ArrayList<>();
        ArrayList<String> category = new ArrayList<>();
        ArrayList<ChartInfoBean.DataBean> listDataBean = new ArrayList<>();
        ChartInfoBean.DataBean dataBean;
        String name = "";
        chartInfoBean.setResLineGradient(R.drawable.char_line_fade_blue);
        legend.add(name);
        chartInfoBean.setLegend(legend);
        dataBean = new ChartInfoBean.DataBean();
        dataBean.setName(name);
        ArrayList<Float> listValue = new ArrayList<>();
        HistoryChartListData flowListData;
        LogUtil.i("getChartInfoBeanPosition----->"+list.size());
        for(int i = 0 ,l = list.size(); i < l ; i ++){
            flowListData = list.get(i);
            category.add(TimeUtils.getTimeLongToStrByFormat(flowListData.getTm(),"HH:mm"));
//            category.add(TimeUtils.getTimeLongToStrByFormat(flowListData.getTm(),"HH:mm"));
            switch (baseListData.getName()){
                case "水位":
                    LogUtil.i("getChartInfoBeanPosition---水位-->"+flowListData.getZ());
                    listValue.add(Float.valueOf(flowListData.getZ()));
                    break;
                case "绝对水位":
                    listValue.add((float) flowListData.getH());
                    break;
                case "气压":
                    listValue.add((float) flowListData.getFl());
                    break;
                case "浊度":
                    listValue.add((float) flowListData.getTurb());
                    break;
                case "溶解氧":
                    listValue.add((float) flowListData.getDoxy());
                    break;
                case "电导率":
                    listValue.add((float) flowListData.getCond());
                    break;
                case "pH":
                    listValue.add((float) flowListData.getPh());
                    break;

            }
        }
        dataBean.setValue(listValue);
        listDataBean.add(dataBean);
        chartInfoBean.setCategory(category);
        chartInfoBean.setData(listDataBean);
        return chartInfoBean;
    }

}
